class Borrowedtable < ActiveRecord::Base
  validates :NameOfDrink, :presence  => true
  validates :product_id , :presence  => true
  validates :NameOfBorrow, :presence => true
  validates :BorrowedDate ,:presence  => true
  validates :Deadline, :presence => true
  def self.paybook(paybook,paybook1)
	#    find(:all, :conditions => ['NameOfBorrow = ? AND NameOfDrink =?', "%#{trasach}%","%#{trasach1}%"])
    #    find(:all, :conditions => ['PayedDate = ?', nil])
        if paybook
    #   find(:all, :conditions => ['NameOfBorrow LIKE ? AND NameOfDrink LIKE ? ', "%#{trasach}%","%#{trasach1}%"])
        find(:all, :conditions => ['NameOfBorrow = ? AND product_id = ? AND PayedDate IS NULL',"#{paybook}","#{paybook1}"])
         else
	    find(:all)
	  end
	end
end
